export function validateAddForm(data,callback){

  // bankName: this.data.bankName,
  // branchName: this.data.bankNode,
  // cardHolder: this.data.phone,
  // cardNo: this.data.bankCode,
  // city: this.data.region[1],      
  // province: this.data.region[0],      
  // smsCode: this.data.code 
    let flg = true
    if(data.smsCode == "") {
      wx.showToast({
        title: '验证码为空',
        icon:"none"
      })
      flg = false
    }

    if(data.phone == "") {
      wx.showToast({
        title: '手机号为空',
        icon:"none"
      })
      flg = false
    }
    

   

    

    if(data.cardHolder == "") {
      wx.showToast({
        title: '账户名称为空',
        icon:"none"
      })
      flg = false
    }

    if(data.cardNo == "") {
      wx.showToast({
        title: '银行卡错误',
        icon:"none"
      })
      flg = false
    }

    if(data.branchName == "") {
      wx.showToast({
        title: '请填写银行支行',
        icon:"none"
      })
      flg = false
    }

    if(data.bankName == "") {
      wx.showToast({
        title: '请填写银行名称',
        icon:"none"
      })
      flg = false
    }
    
    if(data.city == "" || data.city == "城市") {
      wx.showToast({
        title: '城市为空',
        icon:"none"
      })
      flg = false
    }

    if(data.province == "" || data.province == "省份") {
      wx.showToast({
        title: '省份为空',
        icon:"none"
      })
      flg = false
    }
    if(flg){
      callback(flg)
    }
}
// 格式化 银行卡
export function backCardFormat(card){
  let code 
  // var v = this.value;
  if(/\S{5}/.test(card)){
   code = card.replace(/\s/g, '').replace(/(.{4})/g, "$1  ");
   return code
  }else {
    return card
  }
  
}